function closeThis(){
	$('#uploadDialog').modal("hide");
}
/**
*图片上传
*/
function uploadForm(){
	if(!/.(gif|jpg|jpeg|png|GIF|JPG|png)$/.test($('.fileupload-preview').html())){
		$.Alert("图片类型必须是.gif,jpeg,jpg,png中的一种");
		return false;
	}
	$.ajaxFileUpload({  
       url: cxjBasePath +"attachment/uploadFile.json",
       secureuri : false,  
       fileElementId : 'file',// 上传控件的id  
       dataType : 'json', 
       data : {'isPubStorage':$('#isPubStorage').val()}, 
       success: function(data){  
          if(data.status==ajaxStatusSuccess){
        	  $.Alert("上传成功","",function(){
            	  $('#uploadDialog').modal("hide");
            	  var attrPics = $('#attrPics');
            	  if(attrPics.length > 0){
            	  }else{
            		  $('#uploadPic').after('</br><div id="attrPics"></div>');
            		  attrPics = $('#attrPics');
            	  }
            	  attrPics.append('<input type="hidden" id="attachmentImg_'+data.content.id+'" value="'+data.content.id+'">');
            	  var temp='<span onclick = "downloadPic('+data.content.id+');" id="download_'+data.content.id+'" class="btn blue"><i class="icon-search"></i>'+data.content.imgName+'</span><span onclick = "removePic('+data.content.id+');" id="remove_'+data.content.id+'" class="btn red"><i class="icon-search"></i>删除</span>&nbsp;';
            	  attrPics.append(temp);
        	  });
          }else{
          	 $.Alert(data.message);
          }
        },
        error : function(data, status, e) {  
            $.Alert('上传出错');  
        }  
    }) ;
}
	
/**
*打开图片上传页面,参数：上传方式(必传字段,是否公共目录，1：公共 2：私有)
*/
function openUpload(isPubStorage){
	if(isPubStorage == '' || isPubStorage == undefined){
		$.Alert('上传方式不能为空');
		return false;
	}
	var url = cxjBasePath +'attachment/openUpload.pop?isPubStorage='+isPubStorage;
	$.get(url, function(data) {
		$("#uploadDialog").html(data);
	});
	$('#uploadDialog').modal({
		show : true
	});
}


/**
*删除图片
*/
function removePic(id){
	$.ajax({  
		type: "post",  
		url:cxjBasePath+"attachment/ajaxDeleteFile.json",
		dataType:'json',
		data:{'id':id},
		success: function(data){
			if(data && data.status == 'success'){
				$.Alert('删除成功');
				$("#attachmentImg_"+id).remove();
				$("#download_"+id).remove();
				$("#remove_"+id).remove();
			}else{
				$.Alert(data.message);
			}
		},
		error: function(xhr,textStatus,error) {
		}
	}); 
}